<?php
include_once __DIR__.'/config/env_config.php';
include_once __DIR__.'/lib/Helper.php';

$ticketsDataFile = __DIR__."/data/tickets.json";

$lastUpdate = filemtime($ticketsDataFile);
while (true) {
    $now = time();
    if ($now - $lastUpdate > 10*60) {
        $recentTickets = Helper::recentTickets();
        file_put_contents($ticketsDataFile, json_encode($recentTickets));
        echo date('Y-m-d H:i:s', $now)."\t".count($recentTickets);
        echo "\n";
        sleep(3);
    }
    sleep(1);
}
